package com.dal.module.account.platform_verify;

import java.util.Map;

import org.error.LoginErrorCode;

import com.dal.constant.ParamKey;
import com.dal.db.bean.Account;
import com.dal.db.bean.ChannelApp;
import com.dal.db.cache.AccountCache;
import com.sojoys.artifact.exception.AbstractLogicModelException;
import com.sojoys.artifact.tools.ToolError;
import com.xiaoleilu.hutool.util.StrUtil;

/**
 * Created by fxf on 2017/6/22.
 */
@SuppressWarnings("rawtypes")
public class LocalPlatformVerifyer implements PlatformVerifyer {
    @Override
    public void verify(ChannelApp channelApp,Map param) throws AbstractLogicModelException {
		String accountId = (String) param.get(ParamKey.ACCOUNT_ID);
		int channelId = channelApp.getChannelId();
		int channelAppId = channelApp.getId();
		Account account = AccountCache.me().getByAccountIdChannelId(accountId, channelId);
		// 检查激活码参数
		if (account == null && channelApp.isNeedActivateCode()) {
			String activateKye = (String) param.get(ParamKey.ACTIVATE_KEY);
			ToolError.isAndTrue(LoginErrorCode.ACTIVATE_CODE_ERR, StrUtil.isBlank(activateKye));
		}
    }
}
